﻿using System;

namespace Common.Helper
{
    public static class Utility
    {
        /// <summary>
        /// 流水号，24位
        /// </summary>
        public static string SerialNO
        {
            get
            {
                return DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(10, 99).ToString() + new Random().Next(1000, 9999).ToString() + new Random().Next(1000, 9999).ToString();
            }
        }

        /// <summary>
        /// 获取当前时间的时间戳（起始1970-01-01 0：0：0）
        /// </summary>
        /// <param name="thisValue"></param>
        /// <returns></returns>
        public static string DateTimeStamp(this DateTime thisValue)
        {
            TimeSpan ts = thisValue - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            return Convert.ToInt64(ts.TotalSeconds).ToString();
        }
        
    }
}
